<!doctype html>
<html>
<head>
    <!--Setting-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="apple-mobile-web-app-capable"  content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no">
    
    
    <!--Simple SEO-->


<meta name="robots" content=all />
<meta name="google" content=all />
<meta name="googlebot" content=all />
<meta name="verify" content=all />
    <!--Title-->

<title>zabbix2.2 | MIAbon&#39;s blog</title>

<link rel="alternate" href="/atom.xml" title="MIAbon&#39;s blog" type="application/atom+xml">


<link rel="icon" href="/favicon.ico">

    
<link rel="stylesheet" href="/css/base.css">
<link rel="stylesheet" href="/css/pages/post.css">
<link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/thirdParty/highlight/github.css">
<link rel="stylesheet" href="/.css">

    <!--script-->


<script src="http://cdn1.lncld.net/static/js/3.2.1/av-min.js"></script>
<script>
  var appId = "i7AHmC7NPbPtgS3YxT67dRIc-9Nh9j0Va";
  var appKey = "g6TKbY8O4TsCDMcemoC3STvQ";
  var region = "";
  AV.init({
    appId: appId,
    appKey: appKey,
    region: region
  });
</script>


<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

<!--<script src="https://imsun.github.io/gitment/dist/gitment.browser.js"></script>-->


    
    
</head>

<body id="normal">
<!--[if lte IE 8]>
<style>
    html{ font-size: 1em }
</style>
<![endif]-->
<!--[if lte IE 9]>
<style>
    header{ top: 71px; position: absolute!important;}
    #container{padding-top: 151px!important;}
</style>
<div style="position:fixed;z-index:9999;left:0;top:0;width:100%;height:70px;background-color:#e0e0e0;color:#396CA5;border-bottom:1px solid #cecece;text-align:center;line-height:70px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis">你使用的浏览器版本过低，为了你更好的阅读体验，请更新浏览器的版本或者使用其他现代浏览器，比如Chrome、Firefox、Safari等。</div>
<![endif]-->

<div id="wrap">
    <header  style="position: absolute;" >
    <div id="site-meta">
        <a href="/" id="logo">
            <h1 class="title">MIAbon&#39;s blog</h1>
        </a>
        
    </div>
    <ul id="nav">
        
            <li><a href="/"><i class="fa fa-home"></i>首页</a></li>
        
            <li><a href="/atom.xml"><i class="fa fa-rss"></i>RSS</a></li>
        
        <li id="search"><a href="javascript:void(0)"><i class="fa fa-search"></i>搜索</a></li>
    </ul>
</header>

    <div id="container">
        
<ul id="sidebar">
    
    
    
    
<li class="widget widget-normal category">
    <h3 class="fa fa-th widget-title">分类</h3>
    <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/ELK/"><i class="fa" aria-hidden="true">ELK</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Lvs/"><i class="fa" aria-hidden="true">Lvs</i></a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/admin/"><i class="fa" aria-hidden="true">admin</i></a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/ansible/"><i class="fa" aria-hidden="true">ansible</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/aws/"><i class="fa" aria-hidden="true">aws</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/docker/"><i class="fa" aria-hidden="true">docker</i></a><span class="category-list-count">7</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/drone/"><i class="fa" aria-hidden="true">drone</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/kernel/"><i class="fa" aria-hidden="true">kernel</i></a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/kubernetes/"><i class="fa" aria-hidden="true">kubernetes</i></a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/kvm/"><i class="fa" aria-hidden="true">kvm</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/mongodb/"><i class="fa" aria-hidden="true">mongodb</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link current" href="/categories/python/"><i class="fa" aria-hidden="true">python</i></a><span class="category-list-count">9</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/share/"><i class="fa" aria-hidden="true">share</i></a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/web/"><i class="fa" aria-hidden="true">web</i></a><span class="category-list-count">12</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/zabbix/"><i class="fa" aria-hidden="true">zabbix</i></a><span class="category-list-count">3</span></li></ul>
</li>


    
    
<li class="widget widget-normal archive">
  <h3 class="fa fa-archive widget-title">归档</h3>
    <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/02/"><i class="fa" aria-hidden="true">二月 2018</i></a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/01/"><i class="fa" aria-hidden="true">一月 2018</i></a><span class="archive-list-count">8</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/12/"><i class="fa" aria-hidden="true">十二月 2017</i></a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/11/"><i class="fa" aria-hidden="true">十一月 2017</i></a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/10/"><i class="fa" aria-hidden="true">十月 2017</i></a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/09/"><i class="fa" aria-hidden="true">九月 2017</i></a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/08/"><i class="fa" aria-hidden="true">八月 2017</i></a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/05/"><i class="fa" aria-hidden="true">五月 2017</i></a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/04/"><i class="fa" aria-hidden="true">四月 2017</i></a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/03/"><i class="fa" aria-hidden="true">三月 2017</i></a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/01/"><i class="fa" aria-hidden="true">一月 2017</i></a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/12/"><i class="fa" aria-hidden="true">十二月 2016</i></a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/11/"><i class="fa" aria-hidden="true">十一月 2016</i></a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/10/"><i class="fa" aria-hidden="true">十月 2016</i></a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/08/"><i class="fa" aria-hidden="true">八月 2016</i></a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/05/"><i class="fa" aria-hidden="true">五月 2016</i></a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/04/"><i class="fa" aria-hidden="true">四月 2016</i></a><span class="archive-list-count">8</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/05/"><i class="fa" aria-hidden="true">五月 2015</i></a><span class="archive-list-count">1</span></li></ul>
</li>


    
    
<li class="widget widget-normal tags">
  <h3 class="fa fa-tags widget-title">标签云</h3>
  <div class="tagcloud-content">
    
      <a href="/tags/drone/" style="font-size: 0.14rem; color: #69c">drone</a> <a href="/tags/linux/" style="font-size: 0.2rem; color: #0a407c">linux</a> <a href="/tags/kernel/" style="font-size: 0.16rem; color: #4f83b8">kernel</a> <a href="/tags/ELK/" style="font-size: 0.14rem; color: #69c">ELK</a> <a href="/tags/ansible/" style="font-size: 0.14rem; color: #69c">ansible</a> <a href="/tags/swarm/" style="font-size: 0.14rem; color: #69c">swarm</a> <a href="/tags/docker/" style="font-size: 0.18rem; color: #215690">docker</a> <a href="/tags/firewalld/" style="font-size: 0.14rem; color: #69c">firewalld</a> <a href="/tags/zabbix/" style="font-size: 0.16rem; color: #4f83b8">zabbix</a> <a href="/tags/aws/" style="font-size: 0.14rem; color: #69c">aws</a> <a href="/tags/web/" style="font-size: 0.16rem; color: #4f83b8">web</a> <a href="/tags/python/" style="font-size: 0.18rem; color: #215690">python</a> <a href="/tags/spider/" style="font-size: 0.17rem; color: #386da4">spider</a>
  </div>
</li>


    
    
<li class="widget widget-normal friends-link">
    <h3 class="fa fa-globe widget-title">友链</h3><br/>

    
        <a href="http://zhengwei666.wang" class="fa" target="_blank">zhengwei</a>

    
        <a href="https://you-deng.github.io" class="fa" target="_blank">dengyou</a>

    
        <a href="http://www.systemd.cn" class="fa" target="_blank">langyaoliang</a>

    
        <a href="http://www.chen-hao.com.cn/" class="fa" target="_blank">chenhao</a>

    
        <a href="http://www.yulongjun.com" class="fa" target="_blank">yulongjun</a>

    

</li>

    
</ul>


        <div id="main">
    <article id="post">
        <div id="post-header">

            <h1 id="zabbix2.2">
                
                zabbix2.2
                
            </h1>
            <div class="article-meta">
    
    
    <span class="categories-meta fa-wrap">
            <i class="fa fa-folder-open-o"></i>
        <span>zabbix</span>
    </span>
    
    
    <span class="fa-wrap">
         <i class="fa fa-tags"></i>
        <span class="tags-meta">
            
            null
            
        </span>
    </span>
    
    
    <span class="fa-wrap">
        <i class="fa fa-clock-o"></i>
        <span class="date-meta ">2016/08/11</span>
    </span>
    
    
    <span class="fa-wrap">
            <i class="fa fa-thermometer-three-quarters"></i>
        <span class="hits hits-meta " data-leadcloud-title="zabbix2.2"
              data-leadcloud-url="/2016/08/11/zabbix2.2/"><i class="fa fa-spinner fa-spin"></i></span>
    </span>
    
    
</div>

            
            
            <p class="fa fa-exclamation-triangle warning">
                本文于<strong>540</strong>天之前发表，文中内容可能已经过时。如有疑问，请在评论区留言。
            </p>
            
        </div>
        
        <div id="post-body">
            <h1 id="安装nginx"><a href="#安装nginx" class="headerlink" title="安装nginx"></a>安装nginx</h1><p>创建nginx用户<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">useradd -r -s /sbin/nologin nginx</div></pre></td></tr></table></figure></p>
<h1 id="安装依赖包"><a href="#安装依赖包" class="headerlink" title="安装依赖包"></a>安装依赖包</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel ncurses-devel</div></pre></td></tr></table></figure>
<h1 id="创建必要的目录"><a href="#创建必要的目录" class="headerlink" title="创建必要的目录"></a>创建必要的目录</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">mkdir -pv /var/cache/nginx/client_temp</div><div class="line">chown nginx:nginx /var/cache/nginx/client_temp</div><div class="line">mkdir -pv /data/</div><div class="line">mkdir: 已创建目录 <span class="string">"/data/"</span></div><div class="line">chown nginx.nginx /data/</div></pre></td></tr></table></figure>
<p>编译安装<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div></pre></td><td class="code"><pre><div class="line">tar -xf nginx-1.8.1.tar.gz</div><div class="line"><span class="built_in">cd</span> nginx-1.8.1/</div><div class="line">./configure \</div><div class="line">--prefix=/usr/<span class="built_in">local</span>/nginx \</div><div class="line">--sbin-path=/usr/sbin/nginx \</div><div class="line">--conf-path=/etc/nginx/nginx.conf \</div><div class="line">--error-log-path=/var/<span class="built_in">log</span>/nginx/error.log \</div><div class="line">--http-log-path=/var/<span class="built_in">log</span>/nginx/access.log \</div><div class="line">--pid-path=/var/run/nginx.pid \</div><div class="line">--lock-path=/var/run/nginx.lock \</div><div class="line">--http-client-body-temp-path=/var/cache/nginx/client_temp \</div><div class="line">--http-proxy-temp-path=/var/cache/nginx/proxy_temp \</div><div class="line">--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \</div><div class="line">--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \</div><div class="line">--http-scgi-temp-path=/var/cache/nginx/scgi_temp \</div><div class="line">--user=nginx \</div><div class="line">--group=nginx \</div><div class="line">--with-http_ssl_module \</div><div class="line">--with-http_realip_module \</div><div class="line">--with-http_addition_module \</div><div class="line">--with-http_sub_module \</div><div class="line">--with-http_dav_module \</div><div class="line">--with-http_flv_module \</div><div class="line">--with-http_mp4_module \</div><div class="line">--with-http_gunzip_module \</div><div class="line">--with-http_gzip_static_module \</div><div class="line">--with-http_random_index_module \</div><div class="line">--with-http_secure_link_module \</div><div class="line">--with-http_stub_status_module \</div><div class="line">--with-http_auth_request_module \</div><div class="line">--with-threads \</div><div class="line">--with-file-aio \</div><div class="line">--with-pcre \</div><div class="line">make -j 4 &amp;&amp; make install</div></pre></td></tr></table></figure></p>
<p>创建存放站点配置文件的子目录，并修改nginx.conf文件，使其能够加载子目录下的配置文件。<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">cp /etc/nginx/nginx.conf&#123;,.bak&#125;</div><div class="line">mkdir -pv /etc/nginx/conf.d</div></pre></td></tr></table></figure></p>
<p>修改内容为(注意分号必不可少)：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">include /etc/nginx/conf.d/*.conf;</div></pre></td></tr></table></figure></p>
<h1 id="安装php"><a href="#安装php" class="headerlink" title="安装php"></a>安装php</h1><p>安装依赖包<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">yum install -y libxml2 libxml2-devel \</div><div class="line">openssl openssl-devel \</div><div class="line">curl* libcurl* \</div><div class="line">libvpx* libjpeg* \</div><div class="line">libpng libpng-devel \</div><div class="line">freetype* t1lib* \</div><div class="line">zlib zlib-devel \</div><div class="line">zip unzip gzip \</div><div class="line">ncurses* pcre pcre-devel \</div><div class="line">bzip2* gd gd-devel \</div><div class="line">libevent libevent-devel \</div><div class="line">libmcrypt-devel libmcrypt \</div><div class="line">libxslt-devel net-snmp-devel hping2</div></pre></td></tr></table></figure></p>
<p>获取源代码<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">wget http://cn2.php.net/get/php-5.6.24.tar.gz/from/this/mirror</div></pre></td></tr></table></figure></p>
<p>编译安装<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">tar -xvf php-5.6.24.tar.gz</div><div class="line"><span class="built_in">cd</span> php-5.6.24</div><div class="line">./configure --prefix=/usr/<span class="built_in">local</span>/php-5.5.0 --with-config-file-path=/usr/<span class="built_in">local</span>/php-5.5.0/etc --with-bz2 --with-curl --<span class="built_in">enable</span>-ftp--<span class="built_in">enable</span>-socke</div><div class="line">ts --<span class="built_in">disable</span>-ipv6 --with-gd --with-jpeg-dir=/usr/<span class="built_in">local</span> --with-png-dir=/usr/<span class="built_in">local</span> --with-freetype-dir=/usr/<span class="built_in">local</span> --<span class="built_in">enable</span>-gd-native-ttf --wit</div><div class="line">h-iconv-dir=/usr/<span class="built_in">local</span> --<span class="built_in">enable</span>-mbstring --<span class="built_in">enable</span>-calendar --with-gettext --with-libxml-dir=/usr/<span class="built_in">local</span> --with-zlib --with-pdo-mysql=mysqlnd</div><div class="line">--with-mysqli=mysqlnd --with-mysql=mysqlnd --<span class="built_in">enable</span>-dom --<span class="built_in">enable</span>-xml --<span class="built_in">enable</span>-fpm --with-libdir=lib64 --<span class="built_in">enable</span>-bcmath --<span class="built_in">enable</span>-xmlwriter --</div><div class="line"><span class="built_in">enable</span>-xmlreader</div></pre></td></tr></table></figure></p>
<p>提供配置文件<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">cp php.ini-production /usr/<span class="built_in">local</span>/php-5.5.0/etc/php.ini</div><div class="line">cp /usr/<span class="built_in">local</span>/php-5.5.0/etc/php-fpm.conf.default /usr/<span class="built_in">local</span>/php-5.5.0/etc/php-fpm.conf</div></pre></td></tr></table></figure></p>
<p>PHP参数优化<br>编辑/usr/local/php-5.5.0/etc/php-fpm.conf配置文件，修改php-fpm的运行用户为nginx<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">user = nginx</div><div class="line">group = nginx</div></pre></td></tr></table></figure></p>
<p>编辑/usr/local/php-5.5.0/etc/php.ini配置文件，优化以下参数<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">max_execution_time = 300</div><div class="line">memory_limit = 128M</div><div class="line">post_max_size = 16M</div><div class="line">upload_max_filesize = 2M</div><div class="line">max_input_time = 300</div><div class="line">date.timezone = PRC</div></pre></td></tr></table></figure></p>
<p>启动php-fpm<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/usr/<span class="built_in">local</span>/php-5.5.0/sbin/php-fpm</div></pre></td></tr></table></figure></p>
<p>编辑nginx反代php的配置文件<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">cd</span> /etc/nginx/conf.d/</div><div class="line">touch test.conf</div></pre></td></tr></table></figure></p>
<p>编辑test.conf添加以下内容<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line">server&#123;</div><div class="line">listen 80;</div><div class="line">server_name test.maibon.cc;</div><div class="line">access_log off;</div><div class="line">index index.php index.html index.html;</div><div class="line">root /data;</div><div class="line">location /</div><div class="line">&#123;</div><div class="line">try_files <span class="variable">$uri</span> <span class="variable">$uri</span>/ /index.php?<span class="variable">$args</span>;</div><div class="line">&#125;</div><div class="line">location ~ .*\.(php)?$</div><div class="line">&#123;</div><div class="line">expires -1s;</div><div class="line">try_files <span class="variable">$uri</span> =404;</div><div class="line">fastcgi_split_path_info ^(.+\.php)(/.+)$;</div><div class="line">include fastcgi_params;</div><div class="line">fastcgi_param PATH_INFO <span class="variable">$fastcgi_path_info</span>;</div><div class="line">fastcgi_index index.php;</div><div class="line">fastcgi_param SCRIPT_FILENAME <span class="variable">$document_root</span><span class="variable">$fastcgi_script_name</span>;</div><div class="line">fastcgi_pass 127.0.0.1:9000;</div><div class="line">&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>编辑php测试页面<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">&lt;?php</div><div class="line">phpinfo();</div><div class="line">?&gt;</div></pre></td></tr></table></figure></p>
<h1 id="编译安装mysql"><a href="#编译安装mysql" class="headerlink" title="编译安装mysql"></a>编译安装mysql</h1><p>安装编译环境及依赖包<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">yum install –y autoconf automake imake libxml2-devel\</div><div class="line">expat-devel cmake gcc gcc-c++ libaio libaio-devel bzr bison libtool ncurses5-devel</div></pre></td></tr></table></figure></p>
<p>获取源码包并解压缩<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">cd</span> /usr/<span class="built_in">local</span>/src/</div><div class="line">tar -xvf mysql-5.6.13.tar.gz</div><div class="line">创建mysql用户组和用户，及数据库存放目录：</div><div class="line">mkdir -pv /data/mysql/data_3306</div><div class="line">mkdir -pv /data/mysql/binlog</div><div class="line">groupadd mysql</div><div class="line">useradd -g mysql -s /sbin/nologin -r mysql</div><div class="line">chown -R mysql.mysql /data/mysql/</div></pre></td></tr></table></figure></p>
<p>编译安装<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">cmake -DCMAKE_INSTALL_PREFIX=/usr/<span class="built_in">local</span>/mysql -DMYSQL_UNIX_ADDR=/usr/<span class="built_in">local</span>/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8</div><div class="line">_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysql/d</div><div class="line">ata_3306 -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1</div></pre></td></tr></table></figure></p>
<p>编译后修改安装目录的属主属组<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">chown mysql.root /usr/<span class="built_in">local</span>/mysql/</div></pre></td></tr></table></figure></p>
<p>初始化数据库<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">./mysql_install_db --user=mysql --basedir=/usr/<span class="built_in">local</span>/mysql --datadir=/data/mysql/data_3306</div></pre></td></tr></table></figure></p>
<p>提供服务启动配置文件<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">cp /usr/<span class="built_in">local</span>/src/mysql-5.6.13/support-files/my-default.cnf /usr/<span class="built_in">local</span>/mysql/my.cnf</div></pre></td></tr></table></figure></p>
<p>并添加以下内容：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">[mysqld]user = mysql</div><div class="line">port = 3306</div><div class="line">max_allowed_packet = 16M</div><div class="line">max_connect_errors = 1000000</div><div class="line">skip_name_resolve = yes</div><div class="line">datadir = /data/mysql/data_3306</div><div class="line">long_query_time = 1</div><div class="line">sync-binlog = 1</div><div class="line">server-id = 1</div><div class="line">max_binlog_size = 500M</div></pre></td></tr></table></figure></p>
<p>提供服务启动脚本并更改PATH环境变量<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">cp /usr/<span class="built_in">local</span>/src/mysql-5.6.13/support-files/mysql.server /etc/init.d/mysqld_3306</div></pre></td></tr></table></figure></p>
<p>并修改下面两项：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">basedir=/usr/<span class="built_in">local</span>/mysql</div><div class="line">datadir=/data/mysql/data_3306</div><div class="line">chmod +x /etc/init.d/mysqld</div><div class="line">vim /etc/profile.d/mysql.sh</div><div class="line"><span class="comment">#添加的内容： export PATH=/usr/local/mysql/bin/:$PATH</span></div><div class="line"><span class="built_in">source</span> /etc/profile.d/mysql.sh</div></pre></td></tr></table></figure></p>
<p>启动mysql服务并添加开机自启动<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">chkconfig mysqld_3306 on</div><div class="line">service mysqld_3306 start</div><div class="line">mysql安全初始化</div><div class="line">/usr/<span class="built_in">local</span>/src/mysql-5.6.13/scripts/mysql_secure_installation</div></pre></td></tr></table></figure></p>
<h1 id="zabbix安装"><a href="#zabbix安装" class="headerlink" title="zabbix安装"></a>zabbix安装</h1><p>获取源码包<br>下载地址<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">http://www.zabbix.com/download.php</div></pre></td></tr></table></figure></p>
<p>编译安装<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="built_in">cd</span> /usr/<span class="built_in">local</span>/src/</div><div class="line">tar -xvf zabbix-2.2.2.tar.gz</div><div class="line"><span class="built_in">cd</span> zabbix-2.2.2</div><div class="line">./configure --prefix=/usr/<span class="built_in">local</span>/zabbix-2.2.2/ --<span class="built_in">enable</span>-server --<span class="built_in">enable</span>-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2</div><div class="line">make &amp;&amp; make install</div></pre></td></tr></table></figure></p>
<p>创建用户<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line">groupadd zabbix</div><div class="line">useradd -g zabbix -r -s /sbin/nologin zabbix</div><div class="line">初始化数据库</div><div class="line">[root@localhost zabbix-2.2.2]<span class="comment"># mysql -uroot -p</span></div><div class="line">Enter password:</div><div class="line">Welcome to the MySQL monitor. Commands end with ; or \g.</div><div class="line">Your MySQL connection id is 16</div><div class="line">Server version: 5.6.13 Source distribution</div><div class="line">Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.</div><div class="line">Oracle is a registered trademark of Oracle Corporation and/or its</div><div class="line">affiliates. Other names may be trademarks of their respective</div><div class="line">owners.</div><div class="line">Type <span class="string">'help;'</span> or <span class="string">'\h'</span> <span class="keyword">for</span> <span class="built_in">help</span>. Type <span class="string">'\c'</span> to clear the current input statement.</div><div class="line">mysql&gt; create database zabbix default charset utf8;</div><div class="line">Query OK, 1 row affected (0.00 sec)</div><div class="line">mysql&gt; quit</div></pre></td></tr></table></figure></p>
<p>导入三个数据库<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">mysql -uroot -pchangliao.2016 zabbix &lt; database/mysql/schema.sql</div><div class="line">mysql -uroot -pchangliao.2016 zabbix &lt; database/mysql/images.sql</div><div class="line">mysql -uroot -pchangliao.2016 zabbix &lt; database/mysql/data.sql</div></pre></td></tr></table></figure></p>
<p>配置zabbix服务端<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">mkdir /etc/zabbix</div><div class="line">cp config/zabbix_server.conf /etc/zabbix/</div><div class="line">vim /etc/zabbix/zabbix_server.conf</div><div class="line">DBName=zabbix</div><div class="line">DBUser=root</div><div class="line">DBPassword=</div><div class="line">DBPort=3306</div></pre></td></tr></table></figure></p>
<p>更改zabbix的监听端口和监听地址<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">ListenPort=10051</div><div class="line">ListenIP=0.0.0.0</div></pre></td></tr></table></figure></p>
<p>启动zabbix服务端，默认监听在10051，启动时需要指定配置文件路径<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">ln -s /usr/<span class="built_in">local</span>/mysql/lib/libmysqlclient.so.18 /usr/lib64/</div><div class="line">/usr/<span class="built_in">local</span>/zabbix-2.2.2/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf</div></pre></td></tr></table></figure></p>
<p>zabbix客户端安装<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">tar -xvf zabbix-2.2.2.tar.gz</div><div class="line"><span class="built_in">cd</span> zabbix-2.2.2</div><div class="line">./configure --prefix=/usr/<span class="built_in">local</span>/zabbix-2.2.2/ --<span class="built_in">enable</span>-agent</div><div class="line">make &amp;&amp; make install</div></pre></td></tr></table></figure></p>
<p>添加zabbix用户<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">groupadd zabbix</div><div class="line">useradd -g zabbix -s /sbin/nologin -r zabbix</div></pre></td></tr></table></figure></p>
<p>编辑客户端配置文件<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">Server=192.168.100.180</div><div class="line">ServerActive=192.168.100.180</div><div class="line">UnsafeUserParameters=1</div></pre></td></tr></table></figure></p>
<p>启动zabbix客户端<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/usr/<span class="built_in">local</span>/zabbix-2.2.2/sbin/zabbix_agentd -c /usr/<span class="built_in">local</span>/zabbix-2.2.2/etc/zabbix_agent.conf</div></pre></td></tr></table></figure></p>
<p>测试<br>使用zabbix_get测试是否获得数据<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">/usr/<span class="built_in">local</span>/zabbix-2.2.2/bin/zabbix_get -s 192.168.100.20 -p 10050 -k <span class="string">"system.hostname"</span></div></pre></td></tr></table></figure></p>
<p>zabbix管理网站配置<br>拷贝前端文件<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">mkdir -pv /data/logs/nginx</div><div class="line">mkdir -pv /data/zabbix</div><div class="line">cp -rp /usr/<span class="built_in">local</span>/src/zabbix-2.2.2/frontends/php/* /data/zabbix/</div><div class="line">chown -R nginx.nginx /data/zabbix/</div></pre></td></tr></table></figure></p>
<p>配置虚拟主机<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">vim /etc/nginx/conf.d/zabbix.conf</div></pre></td></tr></table></figure></p>
<p>添加以下内容：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line">server&#123;</div><div class="line">listen 80;</div><div class="line">server_name test.miabon.cc;</div><div class="line">access_log /data/logs/nginx/zabbix_access.log;</div><div class="line">index index.php index.html index.html;</div><div class="line">root /data/zabbix;</div><div class="line">location /</div><div class="line">&#123;</div><div class="line">try_files <span class="variable">$uri</span> <span class="variable">$uri</span>/ /index.php?<span class="variable">$args</span>;</div><div class="line">&#125;</div><div class="line">location ~ .*\.(php)?$</div><div class="line">&#123;</div><div class="line">expires -1s;</div><div class="line">try_files <span class="variable">$uri</span> =404;</div><div class="line">fastcgi_split_path_info ^(.+\.php)(/.+)$;</div><div class="line">include fastcgi_params;</div><div class="line">fastcgi_param PATH_INFO <span class="variable">$fastcgi_path_info</span>;</div><div class="line">fastcgi_index index.php;</div><div class="line">fastcgi_param SCRIPT_FILENAME <span class="variable">$document_root</span><span class="variable">$fastcgi_script_name</span>;</div><div class="line">fastcgi_pass 127.0.0.1:9000;</div><div class="line">&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>在浏览器中输入服务器端ip地址</p>

        </div>
        <div id="post-footer">
            <div class="avatar" >
                <img src="/img/author.jpg" alt="avatar"/>
                <!-- 
                <a href="javascript:void(0)" class="high-song">high起来 &#128541;</a>
                 -->
                
                <a href="http://backup-miabon.oss-cn-hongkong.aliyuncs.com/img/alipay.jpg" target="_blank" class="donate fa">打赏小弟 &#128536;</a>
                
            </div>
            <ul class="author-profile-section">
                <li>
                  
                  作者:
                  
                    
                    <a href="/about.html">MIAbon</a>
                </li>
                
                <li>发表日期: <span>2016-08-11  08:00:00</span></li>
                
                <li>最后编辑日期: <span>2017-11-23  08:23:00</span></li>
                
                <li class="post-category">
                    文章分类:
                    
                    <a href="/categories/zabbix/">zabbix</a>
                    
                </li>
                <li class="post-tags">
                    文章标签:
                    
                </li>
                
                <li> 版权声明: <a href="https://creativecommons.org/licenses/by-nc-nd/3.0/" target="_blank">
知识共享署名-非商业性使用-禁止演绎 3.0 未本地化版本许可协议（CC BY-NC-ND 3.0）
</a></li>
                
            </ul>
            <div id="donate-wrap">
                
                
                
                <img src="http://www.geasslinks.com/img/alipay.jpg" alt="支付宝付款" class="donate-img">
                
                
            </div>
        </div>
    </article>
    <div class="article-nav">
        
        <a href="/2016/10/26/在EC2_Linux上挂载S3存储桶/" class="pre-post fa fa-caret-left">在EC2 Linux上挂载S3存储桶</a>
        
        
        <a href="/2016/08/11/Samba/" class="next-post fa">Samba</a>
        
    </div>
    
    <div id="comments">
        

<script>
  gitment.render(document.getElementById("comments"));
</script>



    </div>
    
</div>


    </div>
    <footer id="footer">
    
    <div class="social">
        
        <a href="https://www.example1.com" class="fa fa-free-code-camp" target="_blank" title="freecodecamp"></a>
        
        <a href="https://github.com/werewolf2101" class="fa fa-github" target="_blank" title="Follow me~"></a>
        
        <a href="mailto:werewolf2101@gmail.com" class="fa fa-email" target="_blank" title="Email"></a>
        
    </div>
    
    <div>
        
        <a href="/" class="copyright-links">MIAbon</a>&copy;2015 - 2018.All Rights
        Reserved.
    </div>
    <p>Powered by <a href="https://hexo.io" class="copyright-links" target="_blank">Hexo</a> | Theme by <a
                href="https://github.com/GeekaholicLin" class="copyright-links" target="_blank">GeekaholicLin</a>
    </p>
    
    
    <p>
        <span id="busuanzi_container_site_uv" class="fa fa-bar-chart">
        欢迎第<span id="busuanzi_value_site_uv"><i class="fa fa-spinner fa-spin"></i></span>位小伙伴~
        </span>
    </p>
    
</footer>

</div>
    <ul id="tools">
    <li class="totop-btn fa fa-angle-up"></li>
    <li class="exchange-btn fa fa-exchange"></li>
  
    <li class="toc-btn fa fa-list-ul"></li>
    
    

    
</ul>
<p id="process"></p>
<div id="search-overlay">
    <div class="search-area-wrap">
        <div id="search-area">
            <div class="input-wrap focus">
                <i class="fa fa-search" aria-hidden="true"></i>
                <input id="search-input" autofocus autocomplete="off" type="text"
                       placeholder="search this website..."/>
            </div>
            <ul id="search-result">
                <li class="load-first"><i class="fa fa-spinner fa-pulse"></i></li>
            </ul>
        </div>
    </div>
</div>

    <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#安装nginx"><span class="toc-number">1.</span> <span class="toc-text">安装nginx</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#安装依赖包"><span class="toc-number">2.</span> <span class="toc-text">安装依赖包</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#创建必要的目录"><span class="toc-number">3.</span> <span class="toc-text">创建必要的目录</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#安装php"><span class="toc-number">4.</span> <span class="toc-text">安装php</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#编译安装mysql"><span class="toc-number">5.</span> <span class="toc-text">编译安装mysql</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#zabbix安装"><span class="toc-number">6.</span> <span class="toc-text">zabbix安装</span></a></li></ol>


    <script src="/js/highsong.js"></script>



<script src="/js/search.js"></script>
<script type="text/javascript">
    //theme config datas
    var copyrightObj = {};
    copyrightObj.enable = 'true';
    copyrightObj.triggerCopyLength = '200';
    copyrightObj.appendText = '商业转载请联系作者获得授权,非商业转载请注明出处 © gasslinks.com';
    var leancloudObj = {};
    leancloudObj.enable = 'true';
    leancloudObj.className = 'blog';
    leancloudObj.limits = '5';
</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?dfebe5842f5d4196471b84802392a4b2";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<script type="text/javascript">
    var search = {};
    var search_path = "search.xml";
    if (!search_path) {
        search_path = "search.xml";
    }
    search.path = "/" + search_path;
    search.func =  _ajax.init();
</script>
<script src="/js/app.js"></script>


</body>
</html>